package org.openfans.util;

import org.openfans.UnauthorizedException;
import org.openfans.domain.Fans;
import org.openfans.domain.PreFans;

public final class ThreadFans {
	private static ThreadLocal<Fans> fansHolder = new ThreadLocal<Fans>();

	public static void set(Fans f) {
		fansHolder.set(f);
	}

	public static Fans get() {
		return (Fans) fansHolder.get();
	}

	public static void authorize() throws Exception {
		if (ThreadFans.get() instanceof PreFans) {
			throw new UnauthorizedException("请先登录");
		}
	}
}
